<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
//		$data = array();
//		$data["title"] = "demo this page";
//		$data["content"] = "content demo";
//		$this->load->view('welcome_message', $data);
		// Use whatever user script you would like, just make sure it has an ID field to tie into the ACL with
		$this->load->library('user',array('username'=>'admin','password'=>'abc123') );	
		
		// Get the user's ID and add it to the config array
		$config = array('userID'=>$this->user->getUserID());
		
		// Load the ACL library and pas it the config array
		$this->load->library('acl',$config);
		
		// Get the perm key
		// I'm using the URI to keep this pretty simple ( http://www.example.com/test/this ) would be 'test_this'
		$acl_test = $this->uri->segment(1).'_';
		$acl_test .= ($this->uri->segment(2)!="")?$this->uri->segment(2):'view';
		
		// If the user does not have permission either in 'user_perms' or 'role_perms' redirect to login, or restricted, etc
		if ( !$this->acl->hasPermission($acl_test) ) {
			redirect('/login/');
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */